<template>
	<!-- 入驻签约 -->
	<view class="settled">
		<view class="tip">温馨提示：请前往商家后台电脑端进行签约入驻</view>
		<view class="channel-item" v-for="(item, index) in payChannelList" :key="index">
			<view class="title">
				{{item.payChannelDesc}}
			</view>
			<u-row gutter="16" v-if="item.payChannel == 'wx'">
				<u-col span="6" v-show="subjectType === 'SUBJECT_TYPE_INDIVIDUAL' || !subjectType">
					<view class="wx-item">
						<view class="name">
							个体工商户
						</view>
						<view class="des">
							营业执照上的主体类型一般为个体户、个体工商户、个体经营
						</view>
						<view v-if="sgin" class="tag">
						</view>
						<view v-else class="tag bg-red">
						</view>
					</view>
				</u-col>
				<u-col span="6" v-show="subjectType === 'SUBJECT_TYPE_ENTERPRISE' || !subjectType">
					<view class="wx-item">
						<view class="name">
							企业
						</view>
						<view class="des">
							营业执照上的主体类型一般为有限公司、有限责任公司
						</view>
						<view v-if="sgin" class="tag">
						</view>
						<view v-else class="tag bg-red">
						</view>
					</view>
				</u-col>
			</u-row>
			<u-row gutter="16" v-if="item.payChannel == 'alipay'">
				<u-col span="6">
					<view class="wx-item">
						<view class="name">
							支付宝支付
						</view>
						<view class="des">
							服务集成灵活、安全放心
							方便简单、快速高效
						</view>
						<view class="tag bg-default">
						</view>
					</view>
				</u-col>
			</u-row>
		</view>
	</view>
</template>

<script>
export default {
	data() {
		return {
			payChannelList: [],
			wxStatus: {
				applymentState: '',
				applymentStateMsg: '',
				auditDetail: {},
				signUrl: ''
			},
			 subjectType: '',
			 sgin: false, // 微信是否签约
		}
	},
	onLoad() {
		this.getData()
		this.getWxProgress()
	},
	methods: {
		getData() {
			this.$u.offlineApi.getWxApplyPayChannel().then(res => {
				if(res.code == 0) {
					this.payChannelList = res.data;
				} else {
					uni.showToast({
						icon:'none',
					    title: res.msg
					});
				}
			})
		},
		// 获取微信入驻进度
		getWxProgress() {
		  this.$u.offlineApi.wxProgress().then(res => {
			if (res.code == 0) {
			  this.subjectType = res.data.subjectType;
			  if (res.data.progress < 5) {
				  this.sgin = false;
			  } else {
				this.wxPayChannel()
			  }
			}
		  })
		},
		wxPayChannel() {
			this.$u.offlineApi.wxPayChannel().then(res => {
				if(res.code == 0) {
					this.wxStatus = res.data;
					if (this.wxStatus.applymentState == 'APPLYMENT_STATE_FINISHED') {
						this.sgin = true;
					} else {
						this.sgin = false;
					}
				} else {
					uni.showToast({
						icon:'none',
					    title: res.msg
					});
				}
			})
		}
	}
}
</script>
<style scoped lang="scss">
	.settled {
		font-size: 28rpx;
	}
	.tip {
		padding: 26rpx 30rpx 0 30rpx;
		color: #FC0404;
	}
	.channel-item {
		margin-top: 24rpx;
		padding: 0 30rpx;
		.title {
			padding-left: 10rpx;
			border-left: 6rpx solid #1F6ECF;
			color: #000000;
			font-size: 32rpx;
		}
		.wx-item {
			margin-top: 24rpx;
			padding: 30rpx 20rpx 0 20rpx;
			position: relative;
			width: 315rpx;
			height: 232rpx;
			overflow: hidden;
			font-size: 24rpx;
			background: #FFFFFF;
			border: 2rpx solid #999999;
			border-radius: 10rpx;
		}
		.name {
			color: #000000;
			text-align: center;
		}
		.des {
			margin-top: 20rpx;
			color: #999999;
		}
		.tag {
			  position: absolute;
			  z-index: 2;
			  width: 112rpx;
			  height: 93rpx;
			  right: -2rpx;
			  bottom: 0;
			  background-position: right;
			  background-size: contain;
			  background-repeat: no-repeat;
			  background-image: url(../../../static/offline/my/yi.png);
		}
		.bg-red {
			background-image: url(../../../static/offline/my/wei.png);
		}
		.bg-default {
			background-image: url(../../../static/offline/my/un_open.png);
			
		}
	}
</style>
